<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>跨域</title>
</head>
    <script src="../../static/js/min.js"></script>
<body>
    <button id="btn">原生跨域请求</button>
    <button id="btn2">JQ跨域请求</button>
</body>
    <script>
        // 跨域要用到的域函数
        function print(data){
            console.log('server data is '+data)
        }

        $(function(){
            $("#btn").click(function(){
                var body=document.getElementsByTagName("body")[0]
                var script=document.createElement('script')
                script.type='text/javascript'
                script.src='http://localhost:8000/user/cross_server/?callback=print'
                {#把script 插入到body#}
                body.append(script)
            })
        })

        $(function(){
            $("#btn2").click(function () {
                
                $.ajax({
                url:"http://localhost:8000/user/cross_server/",
                type:'get',
                datatType:'jsonp',
                jsonp:'callback',
                jsonpCallback:'print'
            })
            })
        })

    </script>
</html>

    